{extends file="./main.tpl"}
{block name="head"}
<link href="css/user.css" rel="stylesheet" type="text/css"/>
<script src="js/jquery.min.js"></script>
<script>
function myFunction()
{
	if(confirm("Are You Sure To Delete")== true)
	{
		return true;
	}
	else
	{
		return false;
	}
}
function contractHide()
{
  if($("#contractId").val() > 0)
  {
    $(".contractDtl").hide();
  }
  else
  {
    $(".contractDtl").show();
  }
}
function setValue(obj)
{
  var price = obj.value;
  var quality = $('#contQty').val();
  var conValueVar = price * quality;
  $('#conValue').val(conValueVar);
}

function setValueForInvoiceDetail(obj)
{
  var price = obj.value;
  var quality = $('#qty').val();
  var conValueVar = price * quality;
  $('#valueInvoice').val(conValueVar);
}
function getContractNo()
{
	var dataString = "userId=" + $(".userId").val();
  $.ajax({
	  type: "GET",
	  url: "getContractNo.php",
	  data: dataString,
	  success:function(data){
	    $(".contractId").html(data);  	
	  }
});
}</script>
{/block}
{block name="body"}
<form  action="{$smarty.server.PHP_SELF}" method="post" class="register"> 
<table align="center">
<h1 align="center" style="font-size:px; color:#5BA7E9;">Upload Document</h1>
<tr>
  <th>Users</th>
	<td class=""><label>
	  <select name="userId" required class=" userId " onchange="getContractNo();" AUTOFOCUS>
		  <option value="">Select&nbsp;User</option>
			{html_options values=$userArray.userId output=$userArray.company}
	  </select></label>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  </td>
  <th>Contract&nbsp;No</th>
  <td>
   <span class="contractId">
   	<label>
   	<select name="contractId" id="contractId" class="contractId" onchange="contractHide();" class="text-field">
      <option value="">Select Contract</option>
    </select></label>
   </span>
	</td>
</tr>
</table>
<table align="center">
  <tr>
    <td>
  	  <div class="contractDtl">
  		  <table>
  			  <h2 align="center">Contract Detail</h2>
  			  <tr>
  				  <th>Contract Number</th>
  				  <td><input type="text" name="contractNo" class="text-field"></td>
  		    </tr>
  			  <tr>
  				  <th>Date Of Contract</th>
  				  <td class="text-field">{html_select_date prefix="contDate" start_year ="-0" end_year="+2" field_order="DMY" month_format="%b" day_value_format="%02d"}</td>
  			  </tr>
  			   <tr>
  		  	  <th>Quntity</th>
  		  	  <td><input type="text" name="contQty" id="contQty" class="text-field" ></td>
  		    </tr>
  		    <tr>
  				  <th>Price</th>
  				  <td><input type="text" name="conPrice" class="text-field" onblur="setValue(this);"></td>
  		    </tr>
  		    <tr>
  				  <th>Value</th>
  				  <td><input type="text" name="conValue" id="conValue" class="text-field"></td>
  		    </tr>
  		    <tr>
  				  <th>No Of Invoice</th>
  				  <td><input type="text" name="numOfInvoice" class="text-field"></td>
  		    </tr>
  		    <tr>
  				  <th>Advance Amount</th>
  				  <td><input type="text" name="advAmount" class="text-field"></td>
  		    </tr>
  		    <tr>
  				  <th>Advance Recipt Date</th>
  				  <td class="text-field">{html_select_date prefix="advDate" start_year ="-0" end_year="+2" field_order="DMY" month_format="%b" day_value_format="%02d"}</td>
  			  </tr>
  	    </table>
  	   </div>
    </td>
  </tr>
</table>
<br /><br />
<hr style="color:#c00;" />
<br /><br />
<table align="center">
  <h2 align="center">Invoice Detail</h2>
  <tr>
    <th>Invoice No</th>
    <td><input type="text" name="invoiceNo" class="text-field"></td>
  </tr>
  <tr>
    <th>Quntity No</th>
    <td><input type="text" name="qty" id="qty" class="text-field"></td>
  </tr>
  <tr>
    <th>Price</th>
    <td><input type="text" name="price" id="priceInvoice" class="text-field" onblur="setValueForInvoiceDetail(this);"></td>
  </tr>
  <tr>
    <th>Value</th>
    <td><input type="text" name="value" id="valueInvoice"  class="text-field"></td>
  </tr>
  <tr>
    <th> Date Of Loading</th>
    <td  class="text-field">{html_select_date prefix="loadDate" start_year ="-0" end_year="+2" field_order="DMY" month_format="%b" day_value_format="%02d"}</td>
  </tr>
  <tr>
    <th>Vessel</th>
    <td><input type="text" name="vessel" class="text-field"></td>
  </tr>
  <tr>
    <th>Etd</th>
    <td class="text-field">{html_select_date prefix="etdDate" start_year ="-0" end_year="+2" field_order="DMY" month_format="%b" day_value_format="%02d"}</td>
  </tr>
  <tr>
	  <td colspan="3"><input type="submit" name="submit" value="Submit" class="button"></td>
  </tr>
</table>
</form>
<form class="register1"> 
<table border="0">
	<h2>Contract Detail</h2>
	<tr>
		<th class="text-field">Detail</th>
		<th class="text-field">Delete</th>
		<th class="text-field">Company</th>
		<th class="text-field">Contract Number</th>
		<th class="text-field">Date Of Contract</th>
		<th class="text-field">Quntity</th>
		<th class="text-field">Price</th>
		<th class="text-field">Value</th>
		<th class="text-field">No Of Invoice</th>
		<th class="text-field">Advance Amount</th>
		<th class="text-field">Advance Recipt Date</th>
  </tr>
  {section name="sec" loop=$contractDetailArray}
  <tr>
   <td align="center" class="text-field"><a href="invoiceDetail.php?contractId={$contractDetailArray[sec].contractId}" style="font-size:15px; color:#5BA7E9; text-decoration: none;" class="link"><b>Detail</b></a></td>
   <td align="center" class="text-field"><a href="contractDelete.php?contractId={$contractDetailArray[sec].contractId}" style="font-size:15px; color:#5BA7E9; text-decoration: none;" onclick="return myFunction();" class="link"><b>Delete</b></b></td>
   <td align="center" class="text-field">{$contractDetailArray[sec].company}</td>
   <td align="center" class="text-field">{$contractDetailArray[sec].contractNo}</td>
   <td align="center" class="text-field">{$contractDetailArray[sec].contDate}</td>
   <td align="center" class="text-field">{$contractDetailArray[sec].contQty}</td>
   <td align="center" class="text-field">{$contractDetailArray[sec].conPrice}</td>
   <td align="center" class="text-field">{$contractDetailArray[sec].conValue}</td>
   <td align="center" class="text-field">{$contractDetailArray[sec].numOfInvoice}</td>
   <td align="center" class="text-field">{$contractDetailArray[sec].advAmount}</td>
   <td align="center" class="text-field">{$contractDetailArray[sec].advRptDate}</td>
  </tr>
  {/section}
</table>
</form>
{/block}
